package com.pearadmin.pro.modules.ser.rest;



import com.pearadmin.pro.common.aop.annotation.Log;
import com.pearadmin.pro.common.constant.ControllerConstant;
import com.pearadmin.pro.common.web.base.BaseController;
import com.pearadmin.pro.common.web.domain.Result;
import com.pearadmin.pro.modules.ser.domain.Coffer;
import com.pearadmin.pro.modules.ser.param.CofferRequest;
import com.pearadmin.pro.modules.ser.service.CofferService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * Author: didiplus
 * Email: 972479352@qq.com
 * CreateTime: 2022/3/5
 * Desc:
 */
@Api(tags = {"coffer"})
@RestController
@RequestMapping(ControllerConstant.PREFIX + "coffer")
public class CofferController extends BaseController {
    @Resource
    CofferService cofferService;


    /**
     * 查询密码信息
     *
     * @param request 查询参数
     */
    @GetMapping("list")
    @Log(title = "列表")
    @ApiOperation(value = "列表")
    public Result list(CofferRequest request){
        return success(cofferService.list(request));
    }
    /**
     * 查询服务器信息（分页）
     *
     * @param request 查询参数
     */
    @GetMapping("page")
    @Log(title = "列表")
    @ApiOperation(value = "列表")
    public Result page(CofferRequest request){
        return success(cofferService.page(request));
    }




    /**
     * 修改字典类型
     *
     * @param coffer 字典实体
     */
    @PutMapping("edit")
    @Log(title = "修改信息")
    @ApiOperation(value = "修改信息")
    public Result edit(@RequestBody Coffer coffer) {
        return auto(cofferService.updateById(coffer));
    }

    /**
     * 新增字典值
     *
     * @param serverInfo 查询参数
     */
    @PostMapping("save")
    @Log(title = "新增数据")
    @ApiOperation(value = "新增数据")
    public Result save(@RequestBody Coffer coffer){
        return auto(cofferService.save(coffer));
    }


    /**
     * 删除字典类型
     *
     * @param id 服务器编号
     */
    @DeleteMapping("remove")
    @Log(title = "删除")
    @ApiOperation(value = "删除")
    public  Result remove(@RequestParam String id) {
        return auto(cofferService.removeById(id));
    }


    /**
     * 删除字典类型
     *
     * @param ids 字典实体
     */
    @DeleteMapping("removeBatch")
    @Log(title = "批量删除")
    @ApiOperation(value = "批量删除")
    public Result removeBatch(@RequestParam List<String> ids) {
        return auto(cofferService.removeByIds(ids));
    }
}
